package zee.com.customviewexample.activity

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.view.ViewGroup
import com.zee.extendobject.setBackgroundColorEx
import com.zee.extendobject.setMargin
import com.zee.extendobject.setPadding
import HorizontalLayout
import layoutParamsEx
import setBackgroundEx
import solidColor
import text
import VerticalLayout
import com.zee.extendobject.toColor

/**
 * 代码生成View例子
 */
class MyCustomViewActivity : AppCompatActivity() {
//    override fun getLayoutID(): Int {
//        return R.layout.activity_my_float_window
//    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val linearLayout = VerticalLayout {
            layoutParamsEx(ViewGroup.LayoutParams.MATCH_PARENT)
            text("初始化A", 40).setBackgroundColorEx("#ff0000")
            text("初始化C", 40).setBackgroundColorEx("#ffff00").setPadding {
                padding = 15
                topPadding = 5
                bottomPadding = 5
            }
            text("初始化B", 40, "#c8c8c8").apply {
                setMargin {
                    topMargin = 20
                    leftMargin = 20
                }
                setBackgroundColorEx("#0000ff")
            }
            setBackgroundEx {
                solidColor = "#00ff00".toColor()
            }

            HorizontalLayout {
                text("横向1", 40)
                setPadding {
                    padding = 20
                }
                text("横向2", 40).setMargin { rightMargin = 20 }
                text("横向3", 40)
                text("横向4", 40)
                setBackgroundColorEx("#ff00ff")
                setMargin {
                    topMargin = 20
                    leftMargin = 20
                }
            }
        }
        setContentView(linearLayout)
    }

//    override fun initViews() {
//        float_right.setOnClickListener {
//            MyFloatWindow.init(object : BindViewAdapter(R.layout.item_my_float_window) {
//                override fun initViews(paView: View?) {
//                    setText(R.id.tv_btn, "测试悬浮按钮")
//                }
//            }, "time").showOnForeground(Gravity.RIGHT, 0, 200, this)
//        }
//    }
}
